package com.yxy.f_music_server.controller.mobile;

import com.yxy.f_music_server.common.PageResult;
import com.yxy.f_music_server.common.Result;
import com.yxy.f_music_server.constant.RequestMapperConstant;
import com.yxy.f_music_server.domain.dto.FeedbackDTO;
import com.yxy.f_music_server.domain.dto.FeedbackPageQueryDTO;
import com.yxy.f_music_server.service.FeedbackService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("mobileFeedbackController")
@RequestMapping(RequestMapperConstant.MOBILE_REQUEST_MAPPER + "feedback")
@Slf4j
public class FeedbackController {

    @Autowired
    private FeedbackService feedbackService;

    /**
     * 添加反馈
     * @param feedbackDTO
     * @return
     */
    @PostMapping
    public Result addFeedback(@RequestBody FeedbackDTO feedbackDTO){
        log.info("添加反馈：{}", feedbackDTO);
        feedbackService.add(feedbackDTO);
        return Result.success("提交成功");
    }

    /**
     * 获取反馈列表
     * @param feedbackPageQueryDTO
     * @return
     */
    @GetMapping
    public Result<PageResult> getFeedbackList(FeedbackPageQueryDTO feedbackPageQueryDTO){
        log.info("获取反馈列表：{}", feedbackPageQueryDTO);
        PageResult pageResult = feedbackService.getFeedbackList(feedbackPageQueryDTO);
        return Result.success("", pageResult);
    }
}
